package p5;

/**
 * @author krystal
 * @date 2022/11/10 13:31
 */
public class Demo4 {
    public static void main(String[] args) {
        int[] arr={1,2,3,4,5,6};
        System.out.println(avg(arr));
    }

    public static double avg(int[] arr){
        int sum = 0;
//        for (int i = 0; i < arr.length; i++) {
//            sum += arr[i];
//        }
        for (int x:arr){
            sum += x;
        }
        return (double) sum / (double) arr.length;
    }
}
